package cn.project.demo;

import cn.project.model.Page;
import cn.project.model.User;
import cn.project.service.IUserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/*.xml"})
public class Demo {
    @Resource
    private IUserService userService;

    @Test
    public void demo1(){
        User user=new User();
        user.setUsername("怀里");
        user.setPassword("123");
        userService.addUser(user);
    }
    @Test
    public void demo2(){
        Map<String,Object> cond=new HashMap<>();
        Page page=new Page();
        User user=new User();
        user.setUsername("八戒");
        cond.put("pageSize",2);
        cond.put("pageNum",1);
        cond.put("user",user);
        page=userService.queryLikeUsers(cond);
        System.out.println( page.getResult().get(0));
    }

    public IUserService getUserService() {
        return userService;
    }

    public void setUserService(IUserService userService) {
        this.userService = userService;
    }
}